package com.qf.frist;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author Ypl
 * @version V1.0
 * @Project September-mavens
 * @Package com.qf.frist
 * @Description:
 * @Date 2022/10/8 17:33
 */
@SuppressWarnings("all")
public class HelloQuartz {

    public static void main(String[] args) throws SchedulerException {
        //调度器
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        //触发器
        CronTrigger cronTrigger = TriggerBuilder.newTrigger().
                withIdentity("trigger", "trigger_group").
                //cron表达式
                withSchedule(CronScheduleBuilder.cronSchedule("0-10 * * * * ?")).
                build();
        //任务详情
        JobDetail jobDetail = JobBuilder.newJob(Quartz.class).withIdentity("job", "job_group").build();
        //将任务详情和触发器放入调度器
        scheduler.scheduleJob(jobDetail,cronTrigger);
        //启动调度器
        scheduler.start();
    }
}
